#include "DateCond.h"

using namespace kc_sf;

// ------------------------------------------------- //

DateCond::DateCond (const boost::posix_time::ptime &from_date,
	const boost::posix_time::ptime &to_date)
: c_from_date( from_date ),
  c_to_date( to_date )
{
}
// ------------------------------------------------- //

Logic::Symbol * DateCond::clone() const
{
	return new DateCond( *this );
}

// ------------------------------------------------- //

bool DateCond::eval( const Message &msg )
{
	const boost::posix_time::ptime &came_date = msg.mRawMessage.rmCameDate;

	return c_to_date.is_not_a_date_time()
			? c_from_date.date() == came_date.date()
			: came_date.date() >= c_from_date.date() && came_date.date() <= c_to_date.date();
}

